<?php

namespace View;

class NavigationView {

	
	private static $MovieId = "MovieId";
	private static $Username = "Username";
	const Username = "Username";
	const Movie = "Movie";
	const MovieId = "MovieId";
	const Friend = "Friend"; 
	const MovieFeed = "MovieFeed"; 
	
	//Funktioner som taler om för mastercontroller vilken controller som ska anropas
	public static function isViewingUserPage(){
		
		if (isset($_SESSION[self::Username])){
			
			return true;
		}
		if (isset($_GET[self::Username])){
			return true;
		} else {
			return false;
		}
		
	}
	
	public static function isViewingMovie(){
		
		if (isset($_GET[self::MovieId])){
			
			return true;
		} else {
			return false;
		}
		
	}
	
	public static function IsMovieControllerActive() {

        if (isset($_GET[self::Movie])) {
        
               return true;
        }
		return false;

     }
     
	 public static function IsMovieFeedControllerActive(){
	 	
		 if (isset($_GET[self::MovieFeed])) {
                	
               return true;
		 }
         return false;
	 	
	 }
	 
	 public static function IsFriendControllerActive(){
	 	 	
	 	 if (isset($_GET[self::Friend])) {
                	
                return true;
         }
         return false;
	 	
	 }
	
	
	//Returnerar länk till film
	public static function getMovieLink(\Model\Movie $movie){
		return "?" . self::$MovieId . "=" . $movie->getMovieId();
		
	}
	
	//Returnerar aktuell användare
	public static function getCurrentUser(\Model\UserHandler $userHandler, \Model\Database $db) {
	 	 if (isset($_SESSION[self::Username])) {
	 	 	$username = $_SESSION[self::Username];
			$ret = $userHandler->getUser($username, $db);
            return $ret;
                      
	 	 }
	 }
	 //Returnerar aktuell film
	 public static function getCurrentMovie(\Model\MovieHandler $movieHandler, \Model\Database $db) {
	 	   if (isset($_GET[self::MovieId])) {
		 	 	$movieId = $_GET[self::MovieId];
				$ret = $movieHandler->getMovie($movieId, $db);
	            return $ret;
                      
	 	 }
	 }
}
